package com.errol.batchprocessor.batchprocessor.advisor;

import com.renjia.entity.AbstractImportBatch;
import com.renjia.service.generic.middleware.batchprocessor.abs.AbstractAdvisor;
import com.renjia.service.generic.middleware.batchprocessor.payload.AbstractBatchPayload;
import com.renjia.service.generic.middleware.batchprocessor.payload.AbstractPiecePayload;
import com.renjia.service.generic.middleware.batchprocessor.payload.AbstractSinglePayload;
import org.springframework.lang.NonNull;

/**
 * 单条记录处理结束后的扩展点
 *
 * @author zhang xiao bin
 * @version v1.0
 * @date 2021/02/23
 * @since v5.0.5
 **/
public interface SinglePostAdvisor<IE extends AbstractImportBatch, AT extends Enum<?>, BE, SE, BP extends AbstractBatchPayload<IE, AT, BE, SE>, PP extends AbstractPiecePayload<SE, SP>, SP extends AbstractSinglePayload<SE>>
        extends AbstractAdvisor<AbstractBatchPayload<IE, AT, BE, SE>> {

    /**
     * 单条记录处理结束后（结算或重置）的扩展点，清理缓存
     *
     * @param singlePayload 单条数据
     * @param piecePayload  分片数据
     * @param batchPayload  批次数据
     * @return true 表示执行成功，false 表示执行失败，拦截之后扩展
     */
    boolean doCleanUpOnSinglePost(@NonNull SP singlePayload, @NonNull PP piecePayload, @NonNull BP batchPayload);
}
